package top.jiachunlei.strategy;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @author 朝花不迟暮
 * @version 1.0
 * @date 2020/12/1 20:57
 */
public class StrategyClient
{
    static double total = 0.0d;

    public static void main(String[] args)
    {
        Context ctx;
        String type = getType();
        switch (type)
        {
            case "1":
                ctx = new Context(new CashNormal());
                break;
            case "2":
                ctx = new Context(new CashReturn());
                break;
            default:
                throw new IllegalStateException("Unexpected value: " + type);
        }

        total = ctx.getResult(10.00, 20.00, 30.00);
        System.out.println(total);
    }

    private static String getType()
    {
        try
        {
            BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
            System.out.println("请输入策略：");
            String line = reader.readLine();
            return line;
        } catch (IOException e)
        {
            e.printStackTrace();
            return "";
        }
    }
}
